# Maintainer: Filipe Laíns (FFY00) <lains@archlinux.org>

pkgname=proxmark3
pkgver=4.16191
pkgrel=2
pkgdesc='Software for the the Proxmark3, an RFID swiss-army tool'
arch=('loong64' 'x86_64')
url='https://github.com/RfidResearchGroup/proxmark3'
license=('GPL2')
depends=('qt5-base' 'bluez-libs' 'jansson')
makedepends=('arm-none-eabi-gcc' 'arm-none-eabi-newlib' 'lua52' 'python')
optdepends=('lua52: lua scripts'
            'python: some scripts')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha512sums=('337d114cc2c0a61500c8793f526873d35bb82239e4febf8805880de69a864ee2e104b7750235dcf7eccfc2c39b94231f1fccb6b0f940974a6c08b1b963147d92')

prepare() {
  cp -r $pkgname-$pkgver{,-rdv4}
}

build() {
  cd "$srcdir"/$pkgname-$pkgver

  make PLATFORM=PM3GENERIC SKIPQT=0 all

  cd "$srcdir"/$pkgname-$pkgver-rdv4

  make PLATFORM=PM3RDV4 FWTAG=rdv4 common bootrom recovery fullimage
}

package() {
  export PREFIX=/usr
  export DESTDIR="$pkgdir"
  export UDEV_PREFIX=/usr/lib/udev/rules.d
  export INSTALLTOOLSRELPATH=bin

  cd "$srcdir"/$pkgname-$pkgver-rdv4

  make PLATFORM=PM3RDV4 FWTAG=rdv4 {bootrom,recovery,fullimage}/install

  cd "$srcdir"/$pkgname-$pkgver

  make PLATFORM=PM3GENERIC install
}
